package com.jin.webvideo.controller;

import com.jin.webvideo.parser.ParserManage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/script")
public class ScriptController {
    @Autowired
    private ParserManage manage;

    /**
     * 刷新解析脚本
     * @param name
     * @return
     */
    @ResponseBody
    @GetMapping("/refresh")
    public String reload(@RequestParam(required = false, defaultValue = "") String name){
        manage.reload(name);
        return "SUCCESS";
    }

    /**
     * 清除所有解析脚本的配置信息
     * @param name
     * @return
     */
    @ResponseBody
    @GetMapping("/clear")
    public String clear(@RequestParam(required = false, defaultValue = "") String name){
        ParserManage.clearConfig(name);
        return "SUCCESS";
    }
}
